﻿/* ==============================================================================
 * 功能描述：Singleton  
 * 
 * 创 建 者：郑镇泉
 * 
 * 创建日期：2016/4/3 23:35:42
 * ==============================================================================*/
using UnityEngine;
using System.Collections;

namespace ZZQFrameWork
{
    /// <summary>
    /// c#单例类
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class Singleton<T> where T : class, new()
    {
        private static T _instance;

        public static T Instance
        {
            get
            {
                if (_instance == null)
                {
                    _instance = new T();
                }
                return _instance;
            }
        }

        public Singleton()
        {
            Init();
        }

        /// <summary>
        /// 初始化方法
        /// </summary>
        protected virtual void Init()
        {
        }
    }
}